using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ThemDanhMucPhu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            DanhMucChinh_Ctl DMC = new DanhMucChinh_Ctl();
            DataTable bang = new DataTable();
            bang = DMC.LayDanhMucChinh();
            this.DropDownList1.DataSource = bang;
            this.DropDownList1.DataValueField = "Ma";
            this.DropDownList1.DataTextField = "Ten";
            this.DropDownList1.DataBind();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void btn_Them_Click(object sender, EventArgs e)
    {
        DanhMucPhu_Ctl DMP = new DanhMucPhu_Ctl();
        DMP.Info.MaDanhMucChinh = int.Parse(DropDownList1.SelectedValue.ToString());
        DMP.Info.Ten = txt_TenDMP.Text.ToString();
        if (txt_SoSPDG.Text != "")
            DMP.Info.SoSanPhamDangDauGia = int.Parse(txt_SoSPDG.Text.ToString());
        else
            DMP.Info.SoSanPhamDangDauGia = 0;

        DMP.insert();
        txt_TenDMP.Text = "";
        txt_SoSPDG.Text = "";
    }
}
